##============================================================================
##  The contents of this file are covered by the Viskores license. See
##  LICENSE.txt for details.
##
##  By contributing to this file, all contributors agree to the Developer
##  Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
##============================================================================

##============================================================================
##  Copyright (c) Kitware, Inc.
##  All rights reserved.
##  See LICENSE.txt for details.
##
##  This software is distributed WITHOUT ANY WARRANTY; without even
##  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
##  PURPOSE.  See the above copyright notice for more information.
##============================================================================

list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
  ".*warning: ignoring loop annotation.*"
  ".*warning: Included by graph for.*not generated, too many nodes. Consider increasing DOT_GRAPH_MAX_NODES.*"

  # disable doxygen warnings about no matching members caused by auto keyword
  ".*warning: no matching file member found for.*"

  # disable doxygen warning from VISKORES_DEPRECATED usage
  ".*warning: Found.*while parsing initializer list!.*"

  # disable doxygen warning about potential recursion.
  ".*warning: Detected potential recursive class relation between .*"

  # disable doxygen warning about not generating graph
  ".*warning: Included by graph for"

  # Doxygen warns when creating output directory:
  "Notice: Output directory.*does not exist. I have created it for you."

  # disable doxygen warnings from CONTRIBUTING.md, CodingConventions.md.
  # these files are really intended for Gitlab, hence we don't want to use
  # doxygen tags in them.
  "CONTRIBUTING.md.*warning"
  "CodingConventions.md.*warning"

  # disable static/dynamic weak symbol warnings
  ".*ld: warning: direct access in function.*"

  # disable nvlink warnings about arch not found
  # These indicate that a flag like -arch is missing from the link command.
  # I am seeing these for the Kokkos builds, and I don't want to fight the
  # compiler flags there, so I'm just going to suppress those.
  ".*nvlink warning.*SM Arch.*not found in.*"

  # Disable warning from Macos linker that seems to be a side effect of how
  # GitHub Actions provisions its macos VMs.
  ".*truncating -dylib_current_version to fit in 32-bit space used by old mach-o format.*"

  # Disable warnings about third party libraries.
  # Normally compilers do not generate warnings for includes using -isystem,
  # however, that is not always the case, specially in exotic systems such as
  # OLCF Ascent/Summit
  "viskores/thirdparty"

  # Disable a particular warning that comes from DIY and GCC 12. The warning seems incorrect.
  "12/bits/stl_vector.h:988:50: warning: pointer used after"
  "12/bits/new_allocator.h:158:33: note: call to"

  # This is a warning about not being able to write all the information necessary tracing
  # debugging those variables. This is not an important warning for the builds in our CI.
  # (Developers can resolve the issue if they need to by using a parameter like
  # `--param=max-vartrack-size=600000`. See 
  # https://stackoverflow.com/questions/23499909/adjust-variable-tracking-assignment-length)
  "note: variable tracking size limit exceeded"

  # Disable warning that can happen in the standard lib from the loguru
  # third party library. This is a note that can get flagged because it
  # happens in a file outside of the thirdparty directory.
  ".*'__builtin___snprintf_chk' output between 5 and 12 bytes.*"

  ".*warning: template-id not allowed for constructor.*"
)

list(APPEND CTEST_CUSTOM_WARNING_MATCH
  # Let CUDA compiler warn us about recursive functions we should avoid.
  ".*nvlink warning.*"
  )

## Sometimes a few test hangs in HIP disable repeat until_pass for HIP builds
set(CTEST_REPEAT_UNTIL_PASS 3)
if (NOT x"@CMAKE_HIP_COMPILER@"x STREQUAL xx)
  set(CTEST_REPEAT_UNTIL_PASS 0)
endif()

set(Viskores_ENABLE_PERFORMANCE_TESTING "@Viskores_ENABLE_PERFORMANCE_TESTING@")

# Fail on warnings without stopping the build
# Set maximum number of warnings to 0 to make the build fail on any warning
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 0)
